package com.lv.drawable.drawable

import android.content.res.ColorStateList
import android.graphics.drawable.Drawable
import android.graphics.drawable.RippleDrawable

class RippleBuilder {

    var colors: ColorStateList? = null
    var content: Drawable? = null
    var contentBuilder: (() -> Drawable)? = null
    var mask: Drawable? = null
    var maskBuilder: (() -> Drawable)? = null

    fun color(color: Int) = apply {
        colors = ColorStateList.valueOf(color)
    }

    fun content(builder: () -> Drawable) = apply {
        contentBuilder = builder
    }

    fun mask(builder: () -> Drawable) = apply {
        maskBuilder = builder
    }

    fun build() = RippleDrawable(
        colors ?: throw NullPointerException("RippleBuilder colors null"),
        content ?: contentBuilder?.invoke(),
        mask ?: maskBuilder?.invoke()
    )
}